def isprime(number):
    for i in range(2, number):
        if number % i == 0:
            return False
    return True


primes = [i for i in range(100, 1000) if isprime(i)]
s = {
    "zero": 0,
    "one": 1,
    "two": 2,
    "three": 3,
    "four": 4,
    "five": 5,
    "six": 6,
    "seven": 7,
    "eight": 8,
    "nine": 9,
}
t = input().split()
try:
    l = s[t[0]] * 100 + s[t[1]] * 10 + s[t[2]]
    r = 1000
    z = 0
    for e in primes:
        if abs(e - l) < k:
            k = abs(e - l)
            z = e
    print(z)
except:
    print("Wrong input")
